package com.http;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

public class HttpResponse implements Response {

	private Socket socket;
	private Map<String,String> map=new HashMap<>();
	private int status;
	PrintWriter print;
	public HttpResponse(Socket socket) {
		this.socket = socket;
	}

	@Override
	public void init() {
		try {
			print=new PrintWriter(socket.getOutputStream(),true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void addHeader(String key, String value) {
		map.put(key, value);
	}

	@Override
	public void setStatus(int status) {
		this.status = status;
	}

	@Override
	public PrintWriter getPrintWriter() {
		return print;
	}

	@Override
	public OutputStream getOut() {
		try {
			return socket.getOutputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

}
